#!/usr/bin/env python3
import fileinput
import sys
import os

args = sys.argv[1:]
if len(args) <= 0:
    pass

skip_empty = False
if '--skip-empty' in args:
  skip_empty = True
  args.remove('--skip-empty')


# Each argument is a filename.

# Echo each filename and then the contents of the file.

for filename in args:
    if not os.path.isfile(filename):
        sys.stderr.write('not a file: %s\n' % filename)
        continue

    with open(filename, 'rb') as f:
        text = f.read()#.replace('\r', '')
        if len(text) > 0 or not skip_empty:
            sys.stdout.buffer.write(b'"%%file: %s"\n' % filename.encode('utf-8'))
            sys.stdout.buffer.write(text)
            sys.stdout.buffer.write(b'\n')
            sys.stdout.flush()

